//邮箱自动完成功能 
var nowid;
var totalid;
var can1press = false;  
var emailafter;
var emailbefor;
$(document).ready(function(){
	$("#email").focus(function(){ //文本框获得焦点，插入Email提示层
		$("#myemail").remove();
		$(this).after("<div id='myemail' class='emailChoice' style='left:"+$(this).get(0).offsetLeft+"px; top:"+($(this).get(0).offsetTop+$(this).height()+2)+"px; border:1px solid #ccc;'></div>");
		if($("#myemail").html()){
			$("#myemail").css("display","block");
			can1press = true;
		} else {
			$("#myemail").css("display","none"); 
			can1press = false;
		}
	}).keyup(function(){ //文本框输入文字时，显示Email提示层和常用Email
		var press = $("#email").val();
		if (press!="" || press!=null){
			var emailtxt = "";
			var emailvar = new Array("@163.com","@126.com","@yahoo.com","@qq.com","@sina.com","@gmail.com","@hotmail.com","@foxmail.com");
			totalid = emailvar.length;
			var emailmy = "<div class='newemail'><font color='#D33022'>" + press + "</font></div>";
		if(!(isEmail(press))){
			for(var i=0; i<emailvar.length; i++) {
				emailtxt = emailtxt + "<div class='newemail'><font color='#D33022'>" + press + "</font>" + emailvar[i] + "</div>";
			}
		} else {
			emailbefor = press.split("@")[0];
			emailafter = "@" + press.split("@")[1];
			for(var i=0; i<emailvar.length; i++) {
				var theemail = emailvar[i];
				if(theemail.indexOf(emailafter) == 0){
					emailtxt = emailtxt + "<div class='newemail'><font color='#D33022'>" + emailbefor + "</font>" + emailvar[i] + "</div>";
				}
			}
		}
		$("#myemail").html(emailmy+emailtxt+"<div class='clear'></div>");
		
		$(".newemail").mouseover(function(){ //鼠标经过提示Email时，高亮该条Email
			$(".newemail").css("background","#FFF");
			$(this).css("background","#CACACA");
			$(this).focus();
			nowid = $(this).index();
		}).click(function(){ //鼠标点击Email时，文本框内容替换成该条Email，并删除提示层
			var newhtml = $(this).html();
			newhtml = newhtml.replace(/<.*?>/g,"");
			$("#email").val(newhtml);
			$("#myemail").remove();
		});
	
		if($("#myemail").html()){
			$("#myemail").css("display","block");
			can1press = true;
		} else {
			$("#myemail").css("display","none");
			can1press = false;
		}
		beforepress = press;
		}
		if (press=="" || press==null){
			$("#myemail").html("");
			$("#myemail").css("display","none");
		}
	});	

	$(document).click(function(){ //文本框失焦时删除层
		if(can1press){
			$("#myemail").remove();
			can1press = false;
			if($("#email").focus()){
				can1press = false;
			}
		}
	});


	/*$(document).keydown(function(e){
		if(can1press){
			switch(e.which)
			{
				case 38:
					if (nowid > 0){
						$(".newemail").css("background","#FFF");
						$(".newemail").eq(nowid).prev().css("background","#CACACA").focus();
						nowid = nowid-1;
					}
					if(!nowid){
						nowid = 0;
						$(".newemail").css("background","#FFF");
						$(".newemail").eq(nowid).css("background","#CACACA");
						$(".newemail").eq(nowid).focus();
					}
				break;
				case 40:
					if (nowid < totalid){
						$(".newemail").css("background","#FFF");
						$(".newemail").eq(nowid).next().css("background","#CACACA").focus();
						nowid = nowid+1;
					}
					if(!nowid){
						nowid = 0;
						$(".newemail").css("background","#FFF");
						$(".newemail").eq(nowid).css("background","#CACACA");
						$(".newemail").eq(nowid).focus();
					}
				break;
				//case 13:
					var newhtml = $(".newemail").eq(nowid).html();
					newhtml = newhtml.replace(/<.*?>/g,"");
					$("#email").val(newhtml);
					$("#myemail").remove();	
				//break;	
			}
		}
	});	*/
}); 
//检查email邮箱
	function isEmail(str){
		if(str.indexOf("@") > 0){
		return true;
		} else {
		return false;
		}
	}
$(document).ready(function(){

	//鼠标经过改变样式
	$("input[class='inputStyle01'],input[class='inputStyleTips']").click(
		  function (){
			$('#responsebar').removeClass('tips01');
			$('#responsebar').html('');
			$(this).removeClass('inputStyle01').addClass('inputStyle01Hover'); 
			var tips = $(this).attr("tips");
			if(!$.isempty(tips) && ($(this).parent("p").next("div").attr("class") != "tips01")  && ($(this).parent().parent("li").attr("class") != "infoRight"))  $(this).parent("p").next("div").removeClass("tips01").addClass("tips02").html(tips);
		  }).blur(
		  function (){
			$(this).removeClass('inputStyle01Hover').addClass('inputStyle01');
			if($(this).parent("p").next("div").attr("class") == "tips02") $(this).parent("p").next("div").removeClass("tips02").html('');
		  }
	);
	
	$("input[class='inputStyle02']").click(
		  function (){
			$('#responsebar').removeClass('tips01');
			$('#responsebar').html('');
			$(this).removeClass('inputStyle02').addClass('inputStyle02Hover');
			var tips = $(this).attr("tips");
			if(!$.isempty(tips) && ($(this).parent("p").next("div").attr("class") != "tips01") && ($(this).parent().parent("li").attr("class") != "infoRight") ) $(this).parent("p").next("div").removeClass("tips01").addClass("tips02").html(tips);
		  }).blur(
		  function (){
			$(this).removeClass('inputStyle02Hover').addClass('inputStyle02');
			if($(this).parent("p").next("div").attr("class") == "tips02") $(this).parent("p").next("div").removeClass("tips02").html('');
		  }
	);
	
	
    // $('#frmLogin').find('input:text[@name="user"]').focus();
    $('#frmLogin').find('input:text,input:password').focus(function(){$(this).select();});
    
    $('#alipayLogin').css('cursor','pointer').click( function(){ $('#alipaysubmit').submit();});
	$('#frmLogin').find('input:text[@name="user"]').keyup(function (){$(this).click();});
	$('#frmLogin').find('input:text[@name="user"]').click(
		  function (){
			$('#responsebar').removeClass('tips01');
			$('#responsebar').html('');
			$(this).addClass('inputStyle01Hover').removeClass('inputStyleTips');
		  }).blur(
		  function () {
			if($(this).val() == '') $(this).addClass('inputStyleTips').removeClass('inputStyle01').removeClass('inputStyle01Hover');
		  }
	);



	//注册TAB
	$('#tab_tit').children().each(function(){
			$(this).click(function(){
				$('#tab_tit').children().addClass('topTabNormal').removeClass('topTabAction');
				$('.loginContent').hide();
				$(this).addClass('topTabAction').removeClass('topTabNormal');
				$('#tab_'+$(this).attr('rel')).show();	
			});
	});
	
	//popRegTAB
	$('#pop_regNav').children("span").each(function(){
		$(this).click(function(){
				$('#pop_regNav').children("span").addClass('red');
				$('#tab_reg .loginDetail').hide();
				$(this).removeClass('red');
				$('#tab_'+$(this).attr('rel')).show();	
			});
	});
	 
	//手机注册get_checknum
	$('#get_checknum').click(function(){
		var phone_value = $('form[@name="phoneReg"] input[@id="phone"]').val();
		//alert(phone_value);
		if($.isempty(phone_value) || phone_value.length!=11||! /^1[3578][0-9]\d{8}$/.test(phone_value)){
			//commonPromptPop({'parentId':'auth_reg','promptMsg':'请正确填写您的手机号码。','title':'提示','width':300});
			return;
		}	
		//$.processBlock('auth_reg');
		//$('#responsebar').html('处理中，如果您长时间收不到请关闭重试，或用邮箱注册。');
		var url = g_baseUrls.base+'/auth/msgSend';
		$.ajax({
			type: 'post',
			url: url,
			data : {'user_phone':phone_value,'msg_type':'check','captcha':phone_captcha},
			success: function(resp){try{
						if( !$.isempty(resp) ){
							var retcode = $.dealWithRetInDialog(resp,true);
							//alert(retcode.errcode);需要验证码或验证码错误
							if(retcode.errcode == 113){
								//alert(retcode.errcode);
								var str =  '';
								str +=  '<dl id="phonecheck">';
									str +=  '<dd>手机号码【'+phone_value+'】认证</dd>';
									str +=  '<dd>验证码：<input type="text" class="text" id="phone_captcha" name="phone_captcha" value="" style="width: 160px;ime-mode: disabled;" autocomplete="off" maxlength="4" /></dd>';
									str +=  '<dd><img src="/auth/captcha/size/4>/r/';
									str +=  ((new Date()).getTime())+'"  align="absmiddle" id="regCaptchaPic1" /></dd>';
									str +=  '<dd><input type="button" name="getcheckbyphone" id="getcheckbyphone" value="获取手机验证码"  class="pointer" /></dd>';
								str +=  '</dl>';
								commonPromptPop({'parentId':'tab_phone','promptMsg':str,'title':retcode.info,'width':500});
								
								$('#regCaptchaPic1').click(function(){try{
									$(this)
									.load(function(){$(this).unbind('load');})
									.attr('src','/auth/captcha/size/4/r/'+((new Date()).getTime()));
									
								}catch(e){}});
								
								$('#getcheckbyphone').click(function(){
									phone_captcha = $('#phone_captcha').val();
									if($.isempty(phone_captcha)){
										alert('请输入验证码！');
									}else{
										$('#get_checknum').click();
										$('#commonPromptPopClose').click();
									}
								});
							}else if(retcode.code == 1){
									timeover('get_checknum',60,'再次发送','免费获取手机验证码');
							}else{
								commonPromptPop({'parentId':'tab_phone','promptMsg':retcode.info,'title':'提示信息：','width':500});
							}
						}
					}catch(e){}}
		});
	
	});
	
	//会员卡激活get_pass
	$('#get_pass').click(function(){
		var phone_value =  $('form[@name="cardReg"] input[@id="phone"]').val();
		var user = $('form[@name="cardReg"] input[@id="user"]').val();
		//alert(user);
		if($.isempty(user)){
			//commonPromptPop({'parentId':'auth_reg','promptMsg':'请先填写你的会员卡号后在进行密码获取。','title':'提示','width':300});
			return;
		}
		if($.isempty(phone_value) || phone_value.length!=11||! /^1[34587][0-9]\d{8}$/.test(phone_value)){
			//commonPromptPop({'parentId':'auth_reg','promptMsg':'请正确填写您的手机号码。','title':'提示','width':300});
			$('form[@name="cardReg"] input[@id="phone"]').click();
			return;
		}	
		$.processBlock('auth_reg');
		$('#responsebar').html('处理中，如果您长时间收不到请关闭重试，或联系客服人员。');
		var url = g_baseUrls.base+'/auth/msgSend';
		$.ajax({
			type: 'post',
			url: url,
			data : {'card_no':user,'user_phone':phone_value,'msg_type':'pwd'},
			success: function(resp){try{
						$('#auth_reg').unblock();
						if( !$.isempty(resp) ){
							var retcode = $.dealWithRetInDialog(resp,true);
							$('#responsebar').empty();
							var response_msg = retcode.info;
							if(retcode.code == 1){
								timeover('get_pass',60,'再次发送','免费获取开卡密码');
							}else{
								commonPromptPop({'parentId':'auth_reg','promptMsg':response_msg,'title':'提示','width':300});
								timeover('get_pass',60,'再次发送','免费获取开卡密码');
							}
						}
					}catch(e){}}
		});
	
	});
	
	//验证码
	$('a[name="regCaptchaPic"]').click(function(){
		try{
			$('img[name="regCaptchaPic"]')
			.load(function(){
				$(this).unbind('load');
			})
			.attr('src',g_baseUrls.base+'/auth/captcha/size/4/r/'+((new Date()).getTime()));
		}catch(e){}
	});
	
	
	//登录^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	

	$('.btn_login_2').click(function(){
		$("#frmLogin").ajaxSubmit({
				url : 'http://www.zbird.com/auth/login/',
				success: function(resp){try{
					var retcode = resp.substring(0,1);
					var retinfo = resp.substring(1,resp.length);
					if( retcode == 1 ){
						resp = retcode;
						$('#responsebar').append(retinfo);
					}
					$('#responsebar').show();
					var retcode = $.dealWithRetInDialog(resp,true);
					if(retcode.code == 1){
						$('#responsebar').html('登录中 ...');
						if(!$.isempty(quickform) && $.isempty(redirecto) && (quickform != 'pop')) {
							window.self.location.reload();
						}else{
							var url = redirecto;
							if( retinfo == bankCodeHkbea ){
								url =  g_baseUrls.base+'/banktrack.php4?custreferrekey='+bankCodeHkbea+'&url='+url;
							}
							//登录后的跳转问题，从登出页面和注册页面过来的登录，跳转到首页 2013-7-5 by zhuminghua
							if(('/auth/logout/tojump/1' == url) || ('/auth/reg/tojump/1' == url) || ('/auth/login/tojump/1' == url)){
							    url = g_baseUrls.base;
							}
							
							setTimeout(function(){window.top.document.location.href = url},3000);
						}
					}
					else{
						$('#responsebar').html(retcode.info);
					}
				}catch(e){}}
			});
	})
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv	
	//手机注册表单提交
	if($("#phoneReg").length >0 ){
	$("#phoneReg").validate({
		errorClass: "",
		errorElement: "font",
		success: function(label) {
			label.parent("div").parent("li").removeClass("infoWrong");
			label.parent("div").parent("li").addClass("infoRight");
			label.parent("div").removeClass("tips01");
			label.parent("div").html("");
			$('#msgInput').show();//手机号码输入正确，则显示短信验证框,2013.6.5
		},
		errorPlacement: function(error, element) {
			element.parent("p").parent("li").removeClass("infoRight");
			element.parent("p").parent("li").addClass("infoWrong");
			element.parent("p").next("div").html("");
			error.appendTo(element.parent("p").next("div"));
			element.parent("p").next("div").addClass('tips01');
			$('#msgInput').hide();//手机号码输入错误，则隐藏短信验证框,2013.6.5
		},
		
		
		rules: {
			'phone': {
				required: true,
				mobile:true,
				//remote:  g_baseUrls.base+'/auth/member/ajaxcheck/phone'
				remote:  g_baseUrls.base+'/auth/phoneCheck/ajaxcheck/phone' //验证手机号码的唯一性
			},
			'checker_str': {
				required: true,
				rangeLength: [6,6]
			},
			'nick': {
				required: true,
				mbrangeLength: [4,12],
				remote:  g_baseUrls.base+'/auth/member/ajaxcheck/nick'
			},
			'lpass': {
				required: true,
				rangeLength: [6,36]
			},
			'lrepass': {
				required: true,
				rangeLength: [6,36],
				equalTo: 'form[@name="phoneReg"] input[@type="password"][@name="lpass"]'
			}
		},
		messages: {
			'phone':{
				required: '请输入手机号。',
				remote: '该手机号码已经被注册。'
			},
			'checker_str': {
				required: '请输入手接收的字母',
				rangeLength: '长度必须是6个大写字母'
			},
			'nick': {
				required: '请输入昵称 长度为4-12个字符',
				remote: '昵称已被使用或包含非法字符',
				mbrangeLength: '长度必须是 4 至 12 个字符'
			},
			'lpass': {
				required: '请输入登录网站的密码'
			},
			'lrepass': {
				required: '请再次输入密码',
				equalTo: '重复输入的密码不一致'
			}
		},
		submitHandler: function(form) {
			$("#phoneReg").ajaxSubmit({
				description: '',
				resetForm: false,
				beforeSubmit: function(){
				   
				if($.isempty(quickform))    $.processBlock('auth_reg');
	
				   // notifyReponseBar('提交注册信息中 ...');
				},
				success: function(resp){//try{
					var retcode = $.dealWithRetInDialog(resp,true);
					$('#responsebar').empty();
					var response_msg = retcode.info;
					if(retcode.code == 1){
						$('#responsebar').empty();
						var i = eval('('+retcode.info+')');
						if(!server_test){
							try{
								//if(typeof _gaq == 'undefined') _gaq = [];
								_gaq.push(
									['_addTrans',
									"REG2:"+i.uid,
									"zbird",
									"0.2",
									"0",
									"0",
									"shanghai",
									"shanghai",
									"China"
									],
									['_addItem',
									"REG:"+i.uid,
									i.uid,
									"会员注册",
									"会员注册",
									"0.1",
									"1"
									],
									['_trackTrans']
								);
								//
								
							}catch(e){}
						}
						
						var url = i.url;
						if(quickform == 'pop') {
							regsucc(118704);//AdSage tracking
							if($.isempty(url)){
								window.self.location.reload();
							}else{
								setTimeout(function(){window.top.document.location.href = url;},1500);
							}	
						}else{
							if($.isempty(url)){
								url = g_baseUrls.base+'/auth/regsuccess?user='+i.phone;
								if( !$.isempty(code) ) url += '&code='+code;
							}else{
								if(url.indexOf('?') == -1) url += '?';
							}
							url += '&type=phone';
							
							setTimeout(function(){window.top.document.location.href = url;},1500);
						}
					}
					else{
						
						if(!quickform) $('#auth_reg').unblock();
						
						switch(retcode.errcode){
							case 2:
							$('#frmMemberReg').find('form[@name="phoneReg"] input:password[@name="lpass"]').focus();
							break;
							case 3:
							$('#frmMemberReg').find('form[@name="phoneReg"] input:text[@name="nick"]').focus();
							break;
							case 4:
							$('#frmMemberReg').find('form[@name="phoneReg"] input:text[@name="captcha"]').focus();
							break;
							default:
							$('#frmMemberReg').find('form[@name="phoneReg"] input:text[@name="email"]').focus();
						}
						commonPromptPop({'parentId':'auth_reg','promptMsg':response_msg,'title':'提示','width':300});
					}
				//}catch(e){}
				},
				error: function(){
					 if(!quickform) $('#auth_reg').unblock();
				   // notifyReponseBar('注册信息提交失败，请稍候再试。');
				}
			});
			
			return false;
		}
	});
	}
	
	//邮箱注册表单提交
	if($("#emailReg").length >0 ){
	$("#emailReg").validate({
		errorClass: "",
		errorElement: "font",
		success: function(label) {
			label.parent("div").parent("li").removeClass("infoWrong");
			label.parent("div").parent("li").addClass("infoRight");
			label.parent("div").removeClass("tips01");
			label.parent("div").html("");
		},
		errorPlacement: function(error, element) {
			element.parent().parent("li").removeClass("infoRight");
			element.parent().parent("li").addClass("infoWrong");
			element.parent().siblings("div").html("");
			error.appendTo(element.parent().siblings("div"));
			element.parent().siblings("div").addClass('tips01');
		},
		
		
		rules: {
			'email': {
				required: true,
				email: true,
				remote:  g_baseUrls.base+'/auth/member/ajaxcheck/email'
			},
			'checker_str': {
				required: true,
				rangeLength: [4,4]
			},
			'nick': {
				required: true,
				mbrangeLength: [4,12],
				remote:  g_baseUrls.base+'/auth/member/ajaxcheck/nick'
			},
			'lpass': {
				required: true,
				rangeLength: [6,36]
			},
			'lrepass': {
				required: true,
				rangeLength: [6,36],
				equalTo: 'form[@name="emailReg"] input[@type="password"][@name="lpass"]'
			}
		},
		messages: {
			'email': {
				required: '请输入常用的邮箱地址',
				remote: 'Email地址无效或已经被注册'
			}, 
			'checker_str': {
				required: '请输入验证码',
				rangeLength: '长度必须是4位'
			},
			'nick': {
				required: '请输入昵称 长度为4-12个字符',
				remote: '昵称已被使用或包含非法字符',
				mbrangeLength: '长度必须是 4 至 12 个字符'
			},
			'lpass': {
				required: '请输入登录网站的密码'
			},
			'lrepass': {
				required: '请再次输入密码',
				equalTo: '重复输入的密码不一致'
			}
		},
		submitHandler: function(form) {
			$("#emailReg").ajaxSubmit({
				description: '',
				resetForm: false,
				beforeSubmit: function(){
				   
				if($.isempty(quickform))    $.processBlock('auth_reg');
	
				   // notifyReponseBar('提交注册信息中 ...');
				},
				success: function(resp){//try{
					var retcode = $.dealWithRetInDialog(resp,true);
					$('#responsebar').empty();
					var response_msg = retcode.info;
					if(retcode.code == 1){
						$('#responsebar').empty();
						var i = eval('('+retcode.info+')');
						if(!server_test){
							try{
								//if(typeof _gaq == 'undefined') _gaq = [];
								_gaq.push(
									['_addTrans',
									"REG2:"+i.uid,
									"zbird",
									"0.2",
									"0",
									"0",
									"shanghai",
									"shanghai",
									"China"
									],
									['_addItem',
									"REG:"+i.uid,
									i.uid,
									"会员注册",
									"会员注册",
									"0.1",
									"1"
									],
									['_trackTrans']
								);
							}catch(e){}
						}
						var url = i.url;
						if(quickform == 'pop') {
							regsucc(118703);//AdSage tracking
							if($.isempty(url)){
								window.self.location.reload();
							}else{
								setTimeout(function(){window.top.document.location.href = url;},1500);
							}	
						}else{
							if($.isempty(url)){
								url = g_baseUrls.base+'/auth/regsuccess?user='+i.email;
								if( !$.isempty(code) ) url += '&code='+code;
							}else{
								if(url.indexOf('?') == -1) url += '?';
							}
							url += '&type=mail';
							
							setTimeout(function(){window.top.document.location.href = url;},1500);
						}
					}
					else{
						
						if(!quickform) $('#auth_reg').unblock();
						
						switch(retcode.errcode){
							case 2:
							$('#frmMemberReg').find('form[@name="emailReg"] input:password[@name="lpass"]').focus();
							break;
							case 3:
							$('#frmMemberReg').find('form[@name="emailReg"] input:text[@name="nick"]').focus();
							break;
							case 4:
							$('#frmMemberReg').find('form[@name="emailReg"] input:text[@name="captcha"]').focus();
							break;
							default:
							$('#frmMemberReg').find('form[@name="emailReg"] input:text[@name="email"]').focus();
						}
						commonPromptPop({'parentId':'auth_reg','promptMsg':response_msg,'title':'提示','width':300});
					}
				//}catch(e){}
				},
				error: function(){
					 if(!quickform) $('#auth_reg').unblock();
				   // notifyReponseBar('注册信息提交失败，请稍候再试。');
				}
			});
			
			return false;
		}
	});
	}
	//会员卡激活
	if($("#cardReg").length >0 ){
	$("#cardReg").validate({
		errorClass: "",
		errorElement: "font",
		success: function(label) {
			label.parent("div").parent("li").removeClass("infoWrong");
			label.parent("div").parent("li").addClass("infoRight");
			label.parent("div").removeClass("tips01");
			label.parent("div").html("");
		},
		errorPlacement: function(error, element) {
			element.parent().parent("li").removeClass("infoRight");
			element.parent().parent("li").addClass("infoWrong");
			element.parent().siblings("div").html("");
			error.appendTo(element.parent().siblings("div"));
			element.parent().siblings("div").addClass('tips01');
		},
		
		
		rules: {
			'user': {
				required: true
			},
			'phone': {
				required: true,
				mobile:true,
				remote:  g_baseUrls.base+'/auth/member/ajaxcheck/phone'
			},
			'lpass': {
				required: true
			},
			'checker_str':{
				 required: true,
				 rangeLength: [4,4]
			}
		},
		messages: {
			'user': {
				required: '请输入会员卡号'
			}, 
			'phone':{
				remote: '该手机号码已经被注册。'
			},
			'lpass': {
				required: '请输入登录网站的密码'
			},
			'checker_str': {
				required: '请输入验证码',
				mbrangeLength: '请输入正确验证码'
			}
		},
		submitHandler: function(form) {
			$(form).ajaxSubmit({
				cache: false,
				description: '',
				resetForm: false,
				beforeSubmit: function(){
					if($.isempty(quickform)) $.processBlock('frmLogin');
					notifyReponseBar('提交中 ...');
				},
				success: function(resp){try{
					var retcode = resp.substring(0,1);
					var retinfo = resp.substring(1,resp.length);
					if( retcode == 1 ){
						resp = retcode+'提交成功';
					}
					$('#responsebar').show();
					var retcode = $.dealWithRetInDialog(resp,true);
					var response_msg = retcode.info;
				
					var url = '';
					if(retcode.code == 1){
						
						if(quickform == 'pop') {
							//regsucc(118703);//AdSage tracking
							if($.isempty(url)){
								window.self.location.reload();
							}else{
								setTimeout(function(){window.top.document.location.href = url;},1500);
							}	
						}else{
							
							if(url==''){
								url = g_baseUrls.base+'/auth/regsuccess?user=';
								if( !$.isempty(code) ) url += '&code='+code;
							}else{
								if(url.indexOf('?') == -1) url += '?';
							}
							url += '&type=card';
							
							setTimeout(function(){window.top.document.location.href = url;},1500);
						}
					}
					else{
						commonPromptPop({'parentId':'auth_reg','promptMsg':response_msg,'title':'提示','width':300});
					}
				}catch(e){}}
			});
			// it's important!
			return false;
		}
	});
	}
	
	//找回密码提交表frmFindpass单----------------------------------------------------------------------------------------------------------frmFindpass
	if($("#frmFindpass").length >0 ){
	$("#frmFindpass").validate({
		errorClass: "",
		errorElement: "font",
		success: function(label) {
			label.parent("div").parent("li").removeClass("infoWrong");
			label.parent("div").parent("li").addClass("infoRight");
			label.parent("div").removeClass("tips01");
			label.parent("div").html("");
		},
		errorPlacement: function(error, element) {
			element.parent("p").parent("li").removeClass("infoRight");
			element.parent("p").parent("li").addClass("infoWrong");
			element.parent("p").next("div").html("");
			error.appendTo(element.parent("p").next("div"));
			element.parent("p").next("div").addClass('tips01');
		},
		
		
		rules: {
			'u_phone': {
				required: true,
				mobile:true
			},
			'checker_str': {
				required: true,
				rangeLength: [6,6]
			},
			'lpass': {
				required: true,
				rangeLength: [6,36]
			},
			'lrepass': {
				required: true,
				rangeLength: [6,36],
				equalTo: 'form[@name="frmFindpass"] input[@type="password"][@id="lpass"]'
			}
		},
		messages: {
			'u_phone':{
				required: '请输入手机号。',
				mobile: '请核对手机号。'
			},
			'checker_str': {
				required: '请输入手接收的字母',
				rangeLength: '长度必须是6个大写字母'
			},
			'lpass': {
				required: '请输入登录网站的密码'
			},
			'lrepass': {
				required: '请再次输入密码',
				equalTo: '重复输入的密码不一致'
			}
		},
		submitHandler: function(form) {
			$("#frmFindpass").ajaxSubmit({
				description: '',
				resetForm: false,
				beforeSubmit: function(){
				  $.processBlock('auth_password');
				},
				success: function(resp){//try{
					var retcode = $.dealWithRetInDialog(resp,true);
					$('#responsebar').empty();
					var response_msg = retcode.info;
					if(retcode.code == 1){
						$('#responsebar').empty();
						commonPromptPop({'parentId':'auth_password','promptMsg':response_msg,'title':'提示','width':300});
						var url = g_baseUrls.base+'/auth/login';
						setTimeout(function(){window.top.document.location.href = url;},1500);
					}
					else{
						commonPromptPop({'parentId':'auth_password','promptMsg':response_msg,'title':'提示','width':300});
					}
				},
				error: function(){
					$('#auth_password').unblock();
				}
			});
			
			return false;
		}
	});
	}
	//重设密码提交表单frmResetpass----------------------------------------------------------------------------------------------------------frmResetpass
	if($("#frmResetpass").length >0 ){
	$("#frmResetpass").validate({
		errorClass: "",
		errorElement: "font",
		success: function(label) {
			label.parent("div").parent("li").removeClass("infoWrong");
			label.parent("div").parent("li").addClass("infoRight");
			label.parent("div").removeClass("tips01");
			label.parent("div").html("");
		},
		errorPlacement: function(error, element) {
			element.parent("p").parent("li").removeClass("infoRight");
			element.parent("p").parent("li").addClass("infoWrong");
			element.parent("p").next("div").html("");
			error.appendTo(element.parent("p").next("div"));
			element.parent("p").next("div").addClass('tips01');
		},
		
		
		rules: {
			'lpass': {
				required: true,
				rangeLength: [6,36]
			},
			'lrepass': {
				required: true,
				rangeLength: [6,36],
				equalTo: 'form[@name="frmResetpass"] input[@type="password"][@name="lpass"]'
			}
		},
		messages: {
			'lpass': {
				required: '请输入登录网站的密码'
			},
			'lrepass': {
				required: '请再次输入密码',
				equalTo: '重复输入的密码不一致'
			}
		},
		submitHandler: function(form) {
			$("#frmResetpass").ajaxSubmit({
				description: '',
				resetForm: false,
				beforeSubmit: function(){
				    $.processBlock('auth_password');
				},
				success: function(resp){//try{
					var retcode = $.dealWithRetInDialog(resp,true);
					$('#responsebar').empty();
					var response_msg = retcode.info;
					if(retcode.code == 1){
						$('#responsebar').empty();
						commonPromptPop({'parentId':'auth_password','promptMsg':response_msg,'title':'提示','width':300});
						var url = g_baseUrls.base+'/auth/login';
						setTimeout(function(){window.top.document.location.href = url;},1500);
					}
					else{
						commonPromptPop({'parentId':'auth_password','promptMsg':response_msg,'title':'提示','width':300});
					}
				},
				error: function(){
					  $('#auth_password').unblock();
				}
			});
			
			return false;
		}
	});
	}
});


//倒计时
function timeover(obj,t,txt,text){
	var count = t;
	var butTime = function(){
		var butNode = $('#'+obj);
		//alert(butNode.val());
		butNode.css('cursor','not-allowed');
		butNode.css('color','#ffffff');
		butNode.attr("disabled",true);
		butNode.val(count+"秒后"+txt);
		count--;
		if(count<=0)
		{
		butNode.val(text);
		butNode.attr("disabled",false);
		butNode.css('cursor','pointer');
		butNode.css('color','#ffffff');
		window.clearInterval(time);
		}
	};
	var time;
	butTime();
	time = window.setInterval(butTime,1000);
}

//关闭弹出窗口
$('#auth_pop_close').click(function(){
  		$('#memberLoginPopDiv').remove();
  		$(document.body).unblock();
  	});
/*$('#auth_pop_close').click(function(){
	$('#productDetailPop').hide('slow');
	closeCenterDiv();
});*/


//手机找回密码
	$('#find_checknum').click(function(){
		var phone = $('#yzphone').val();
		var captcha_hash_reg = $('#captcha_hash_reg').val();
		if($.isempty(phone) || phone.length!=11||! /^1[3578][0-9]\d{8}$/.test(phone)){
			commonPromptPop({'parentId':'auth_password','promptMsg':'请正确填写您的手机号码。','title':'提示','width':300});
			return false;
		}	
		timeover('find_checknum',60,'再次发送','免费获取验证码');
		var url = g_baseUrls.base+'/auth/msgSend';
		$.ajax({
			type: 'post',
			url: url,
			data : {'user_phone':phone,'msg_type':'findpass','captcha_hash_reg':captcha_hash_reg},
			success: function(resp){try{
						$('#auth_reg').unblock();
						if( !$.isempty(resp) ){
							var retcode = $.dealWithRetInDialogMsg(resp,true);
							$('#responsebar').empty();
							var response_msg = retcode.info;
							$('#captcha_hash_reg').val(retcode.rdStr);//添加随机码赋值功能
							commonPromptPop({'parentId':'auth_password','promptMsg':response_msg,'title':'提示','width':300});
						}
					}catch(e){}}
		});
	
	});
//邮件找回密码：
	$('#find_back,#again_email').click(function(){
		var u_email = $('.myemail').val();
		var Captcha =  $('.checker_captcha').val();
		if($.isempty(u_email) || !isEmail(u_email)){
			commonPromptPop({'promptMsg':'请刷新页面从新填写邮箱。','title':'提示','width':300});
			return false;
		}
		$.ajax({
			type: 'post',
			url: g_baseUrls.base+'/auth/findpass/',
			data : {'flg':'email','u_email':u_email,'Captcha':Captcha, 'act':5},
			dataType : 'json',
			success: function(res){
				if(res.code == 200){
				  timeover('again_email',60,'再次发送','获取邮箱验证');
                  $('#passtwo').submit();
                }else{
                  alert(res.msg);
                }
			}
		});
	
	})


/*验证码跟新*/
function authCode(){
    try{
        $('#auchcodeG')
        .load(function(){
            $(this).unbind('load');
        })
        .attr('src',g_baseUrls.base+'/auth/captcha/size/4/r/'+((new Date()).getTime()));
        
    }catch(e){}
}